# 文件名: launch_all.py
from launch import LaunchDescription
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
    # rplidar_ros launch
    rplidar_launch_dir = get_package_share_directory('rplidar_ros')
    rplidar_launch_file = os.path.join(rplidar_launch_dir, 'launch', 'rplidar_s2_launch.py')
    rplidar_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(rplidar_launch_file),
        launch_arguments={
            "serial_port":"/dev/ttyUSB1"
        }.items()
    )

    # can_decode launch
    ugv_base_dir = get_package_share_directory('sls_launch')
    ugv_base_file = os.path.join(ugv_base_dir, 'launch', 'ugv_base.launch.py')
    ugv_base_launch = IncludeLaunchDescription(
        PythonLaunchDescriptionSource(ugv_base_file),
        launch_arguments={
            "RTK_serial_port":"/dev/ttyUSB0"
        }.items()
    )

    return LaunchDescription([
        rplidar_launch,
        ugv_base_launch
    ])
